
Ext.Loader.setConfig({enabled:true
});
Ext.QuickTips.init();
//--------
Ext.Loader.setPath({
	'Ext.ux' : 'extjs4/ux',
	'Ext.app' : 'extjs4/app'
});
Ext.Ajax.on('requestcomplete', function(conn, response, options, e){  
        var s = response.responseText;  
        if(s.indexOf("系统登录")>0){  
        	Ext.Msg.show({title:'ThinkGSP',msg:'登录超时,请重新登录!',buttons:Ext.Msg.OK,icon:Ext.Msg.WARNING,fn:function(){
        		window.location.href = "index.jsp"; 
        	}});	
             
        }  
 });  
Ext.require(['Ext.app.Portlet', 'Ext.app.PortalColumn', 'Ext.app.PortalPanel',
		'Ext.app.PortalDropZone', 'Ext.ux.TabReorderer',
		'Ext.ux.TabCloseMenu']);
var loginUser;
//本地数据缓存
var dataCache = new Ext.util.MixedCollection();
var ajax = function(config) { // 封装、简化AJAX
	Ext.Ajax.request({
				url : config.url, // 请求地址
				params : config.params, // 请求参数
				method : 'post', // 方法
				callback : function(options, success, response) {
					config.callback(Ext.JSON.decode(response.responseText));
					// 调用回调函数
				}
			});
	return false;
};
var isDebug=true;
var showExtReturnMsg=function(response,isShowSuccess,title){
	var isShow=true;
	if(isShowSuccess!=null)
		isShow=isShowSuccess;
	var tt=title==null? "ThinkGSP":title;
	var data=Ext.JSON.decode(response.responseText);
	if(data.success && isShow){
		Ext.MessageBox.alert(tt,data.msg);
		Ext.Msg.show({title:tt,
	       msg:data.msg,
	       buttons: Ext.Msg.OK,
	       icon: Ext.Msg.INFO
	    });
	}
	else{
		if(isDebug){
			if(Ext.isEmpty(data.o)){
				Ext.Msg.show({title:tt,
			       msg:data.msg,
			       buttons: Ext.Msg.OK,
			       icon: Ext.Msg.INFO
			    });
			}
			else{
				var omsg=data.o.message;
				if(Ext.isEmpty(omsg)){
					omsg=data.o;
				}
				Ext.Msg.show({title:tt,
			       msg:data.msg+" :<br/>" +omsg,
			       buttons: Ext.Msg.OK,
			       icon: Ext.Msg.INFO
			    });
			}
		}
		else{
			Ext.Msg.show({title:tt,
		       msg:data.msg,
		       buttons: Ext.Msg.OK,
		       icon: Ext.Msg.INFO
		    });
		}
	}
};

var showStoreLoadException=function(options){
	if(options.exception){
		var str=options.getError().statusText;
		switch(options.getError().stauts)
		{
			case 400:str='无法解析此请求,请确认参数是否正确';break;
			case 401:str='未授权,登录失败 ';break;
			case 403:str='访问被拒绝';break;
			case 500:str='Web 服务器不能执行此请求。请稍后重试';break;
			case 502:str='网关出错 ';break;
			case 404:str='Web 服务器找不到您所请求的文件或脚本。请检查URL 以确保路径正确';break;
			default:str='未知错误';
		}
		Ext.Msg.show({title:'ThinkGSP',msg:'查询数据出错:'+str,buttons:Ext.Msg.OK,icon:Ext.Msg.WARNING});					
	}
};
//----------------
Ext.application({
	name:'TS',
	appFolder:'app',
	autoCreateViewport: true, 
    controllers: [//'Main',
       'AccordionMenu','Users','Emp','Customer','RpARecBills','Product','RpAPayBills',
       'RpRecBills','Inventory','SaleBills','SaleBillEditors','SalePriceDiffBills','SalePriceDiffBillEditorCtl',
       'PurchaseBills',
       'PurchaseBillEditors',
       'RejectStockInBills',
       'RejectStockInBillEditorCtl',
       'RejectStockOutBills',
       'RejectStockOutBillEditorCtl',
       'OtherOutBills',
       'OtherOutBillEditorCtl',
       'OtherInBills',
       'OtherInBillEditorCtl',
       'StockTransferBills',
       'StockTransferBillEditorCtl',
       'ProductTransferBills',
       'ProductTransferBillEditorCtl'
       ,'RpPayBills'
       ,'RpRecBillEditors'
       ,'RpPayBillEditors'
       ,'TS.controller.RpARecSheets'
       ,'TS.controller.RpAPaySheets'
       ,'TS.controller.RpCustomerContacts'
       ,'RpARecChecks'
       ,'RpARecCheckEditors'
       ,'RpAPayChecks'
       ,'RpAPayCheckEditors'
       ,'PeriodEndForwards'
       ,'DataImports'
    ]
});
